package com.sh15tech.mp.weixin.modal;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import org.springframework.jdbc.core.RowMapper;

public class WxMessageRowMapper implements RowMapper<WxMessage> {

	@Override
	public WxMessage mapRow(ResultSet rs, int rowNum) throws SQLException {
		WxMessage t = new WxMessage();
    	t.setId(rs.getInt("ID"));
    	t.setMemberId(rs.getString("MEMBER_ID"));
    	t.setMsgTitle(rs.getString("MSG_TITLE"));
    	t.setMsgContent(rs.getString("MSG_CONTENT"));
    	t.setMsgType(rs.getInt("MSG_TYPE"));
    	t.setMsgState(rs.getInt("MSG_STATE"));
    	if(rs.getTimestamp("ENROLLMENT_TIME") != null){
    		t.setEnrollmentTime(new Date(rs.getTimestamp("ENROLLMENT_TIME").getTime()));
    	}
    	if(rs.getTimestamp("TRIGGER_TIME") != null){
    		t.setTriggerTime(new Date(rs.getTimestamp("TRIGGER_TIME").getTime()));
    	}
    	t.setOpUser(rs.getString("OP_USER"));
    	t.setOpTime(new Date(rs.getTimestamp("OP_TIME").getTime()));
    	t.setOpenId(rs.getString("OPENID"));
        return t;
	}

}
